from models.Comment import Comment
from models.models import Model


class Weibo(Model):
    def __init__(self, form, user_id=-1):
        self.id = form.get('id', None)
        self.content = form.get('content', '')
        # 数据的关联，用user_id表命拥有他的user实例
        self.user_id = form.get('user_id', user_id)

    def comments(self):
        return Comment.find_all(weibo_id=self.id)
